import uuid

import wmi

from src.python.tools.singleton import singleton


@singleton
class computerCode:
    def __init__(self):
        self.mac_address = hex(uuid.getnode())[2:]

        c = wmi.WMI()
        for physical_disk in c.Win32_DiskDrive():
            self.disk_serial_number = physical_disk.SerialNumber
            break

        for processor in c.Win32_Processor():
            self.cpu_serial_number = processor.ProcessorId.strip()
            break

        self.machine_code = self.mac_address + self.disk_serial_number + self.cpu_serial_number

    def getMachineCode(self):
        return self.machine_code
